home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / include / oscillat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-05  |  935 b   |  42 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknowledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef Oscillator_h
  13. #define Oscillator_h
  14.  
  15. #include <bool.h>
  16.  
  17. class Cycle {
  18. public:
  19.     Cycle() : Period(2), Throb(2) {}
  20.     Cycle(int n) : Period(n), Throb(n) {}
  21.     bool operator() () { if (!--Throb) Throb=Period; return Throb==Period; }
  22.     void Rate(int R) { Period=R; Throb=R; }
  23.  
  24. public:
  25.     int Period;
  26.     int Throb;
  27. };
  28.  
  29. class Oscillator {
  30. public:
  31.     Oscillator(int min,int max);
  32.     operator int() { return Throb; }
  33.     int Oscillate();
  34.  
  35. private:
  36.     int Min,Max;
  37.     int Throb;
  38.     int Way;
  39. };
  40.  
  41. #endif
  42.